package Thread.Thread05;

import java.util.concurrent.*;

public class TreadTest2 {
//掌握线程池的创建

    public static void main(String[] args) throws ExecutionException, InterruptedException {

        ThreadPoolExecutor pool = new ThreadPoolExecutor(3, 5, 8, TimeUnit.SECONDS, new ArrayBlockingQueue<>(4), new ThreadPoolExecutor.CallerRunsPolicy());

        //使用线程处理callable线程任务
        Future<String> submit = pool.submit(new MyCallble(100));
        Future<String> submit2 = pool.submit(new MyCallble(200));
        Future<String> submit3 = pool.submit(new MyCallble(300));
        Future<String> submit4 = pool.submit(new MyCallble(400));

        System.out.println(submit.get());
        System.out.println(submit2.get());
        System.out.println(submit3.get());
        System.out.println(submit4.get());

    }
}
